Computer systems are classically defined as having three main blocks: central processing unit (CPU), memory, and input/output peripherals. Microcontrollers, which are also known as microcomputers or embedded controllers, incorporate all three of these blocks onto a single integrated circuit chip. Microcontrollers are used for a variety of control applications such as microwave ovens, television remote controllers, cellular telephones, and the like. Depending on the application, the microcontroller may either be able to have all program code on-chip, or it may have some program code on-chip and some program code off-chip. For these applications, some microcontrollers are designed to operate in an "expanded mode", in which address and data signals are present on integrated circuit pins and thus the microcontroller can access some program code off-chip.
In certain applications it is important to protect the program code from reverse engineering or "hacking". While this program code may be protected from legal copying through copyright laws, additional measures are required to prevent "hackers" from illegally copying and redistributing this code. If the program code is located in an off-chip memory, a hacker may simply pull the program memory chips out of their sockets and read out their data using separate hardware. If the program code is completely on-chip, hacking at least becomes more difficult. However well-known integrated circuit reverse engineering techniques allow the contents of this on-chip program memory to be determined relatively easily as well. Furthermore in many applications in which the software is complicated, such as cellular telephones, the code is usually too large to fit completely on-chip. Thus part of the program code must be located off-chip and the microcontroller must access it in expanded mode. In order to protect this valuable code which may be partially off-chip, certain microcontrollers have implemented address and data encryption techniques.
Address encryption consists generally of scrambling the physical locations within the microcontroller's internal memory so that hackers cannot read out the code by determining the logic states of memory cells and knowing the sequence due to the physical location of the memory cells. Data encryption includes both encryption and decryption. Data is encrypted when it is passed from the internal memory to external memory, and decrypted when it is read from external memory into the CPU or internal memory. There are many well known encryption schemes which use mathematical transformations and may even use the address location of the data as part of the transformation.
With regard to program instructions and data which are stored in external memory but which are brought on-chip as the program demands, encryption is a valuable tool in making it more difficult to hack a program. The programmer knows the encryption scheme and is able to store the program in the external memory chips in encrypted form. However these microcontrollers are frequently connected to external peripherals as well. For example, the data processor might need to drive a seven-segment display or read data from a terminal. In that case, encryption presents a couple of problems. First, encryption would increase the cost of system elements if they too had to include encryption and/or decryption circuitry. Second, the microcontroller manufacturer may have to disclose the encryption techniques used on the microcontroller to the manufacturer of the peripheral, which would increase the chance that the encryption scheme will leak out. What is needed, then, is a data processor such as a microcontroller which has a more flexible encryption scheme to allow for external peripherals. The present invention provides such a data processor, whose features and advantages will be more clearly understood from the following detailed description taken in conjunction with the accompanying drawings.